package com.zhaokuner.dockerdemo.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author 赵希坤 zhaoxikun
 * @date 2022/1/8 15:33
 */
@RestController
@RequestMapping
public class RootCtrl {

    @RequestMapping("/{str}/**")
    public Object root(@PathVariable String str, HttpServletRequest request){
        System.out.println(str);
        return str;
    }

    @Autowired
    RedisTemplate<String,String> redisTemplate;

    @RequestMapping("/redis/**")
    public Object redis(){
        redisTemplate.opsForValue().set("time",new Timestamp(System.currentTimeMillis()).toString());
        return redisTemplate.opsForValue().get("time");
    }
}
